//
//  YAYIPerformanceDetailCell.m
//  YAYIDoctor
//
//  Created by Veer on 16/5/10.
//  Copyright © 2016年 hxp. All rights reserved.
//

#import "YAYIPerformanceDetailCell.h"
#import "YAYIPerformanceDetailModel.h"


@interface YAYIPerformanceDetailCell()

@property (nonatomic, weak) UILabel *hospitalLbl;
@property (nonatomic, weak) UILabel *patientNameLbl;
@property (nonatomic, weak) UILabel *serviceItemLbl;
@property (nonatomic, weak) UILabel *timeLbl;
@property (nonatomic, weak) UIView *lineView;

@end

@implementation YAYIPerformanceDetailCell

- (void)setModel:(YAYIPerformanceDetailModel *)model
{
    _model = model;
    
    self.hospitalLbl.text = model.hospitalname;
    self.patientNameLbl.text = [NSString stringWithFormat:@"就诊人:%@", model.patientname];
//    self.serviceItemLbl.text = model.services;
    self.timeLbl.text = model.workday;
    
}

+ (instancetype)cellWith:(UITableView *)tableview
{
    static NSString *cellID = @"YAYIPerformanceDetailCell";
    
    YAYIPerformanceDetailCell *cell = [tableview dequeueReusableCellWithIdentifier:cellID];
    
    if (nil == cell) {
        cell = [[YAYIPerformanceDetailCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
    }
    
    return cell;
}



- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        [self setupSubView];
    }
    return self;
}


- (void)setupSubView
{
    // 医院名
    UILabel *hospitalLbl = [[UILabel alloc] init];
    hospitalLbl.text = @"杭州空腔医院";
    hospitalLbl.font = [UIFont systemFontOfSize:17];
    [self.contentView addSubview:hospitalLbl];
    self.hospitalLbl = hospitalLbl;
    
    // 就诊人
    UILabel *patientNameLbl = [[UILabel alloc] init];
    patientNameLbl.text = @"就诊人：张三";
    patientNameLbl.textColor = YAYIColor(119, 122, 126);
    patientNameLbl.font = [UIFont systemFontOfSize:16];
    [self.contentView addSubview:patientNameLbl];
    self.patientNameLbl = patientNameLbl;
    
    // 服务项目
//    UILabel *serviceItemLbl = [[UILabel alloc] init];
//    serviceItemLbl.text = @"服务项目：拔牙";
//    serviceItemLbl.textColor = YAYIColor(119, 122, 126);
//    serviceItemLbl.font = [UIFont systemFontOfSize:16];
//    [self.contentView addSubview:serviceItemLbl];
//    self.serviceItemLbl = serviceItemLbl;
    
    // 时间
    UILabel *timeLbl = [[UILabel alloc] init];
    timeLbl.text = @"就诊时间：2016-4-2";
    timeLbl.textColor = YAYIColor(119, 122, 126);
    timeLbl.font = [UIFont systemFontOfSize:16];
    [self.contentView addSubview:timeLbl];
    self.timeLbl = timeLbl;
    
    // 线
    UIView *lineView = [[UIView alloc] init];
    lineView.backgroundColor = YAYICellLineColor;
    [self.contentView addSubview:lineView];
    self.lineView = lineView;
}


- (void)layoutSubviews
{
    [super layoutSubviews];
    
    [self.hospitalLbl mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@20);
        make.top.equalTo(@10);
    }];
    
    
    [self.timeLbl mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@20);
        make.bottom.equalTo(@-10);
    }];
    
    [self.patientNameLbl mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@20);
        make.bottom.equalTo(self.timeLbl.mas_top).offset(-3);
    }];
    
//    [self.serviceItemLbl mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.left.equalTo(self.patientNameLbl.mas_right).offset(20);
//        make.bottom.equalTo(self.timeLbl.mas_top).offset(-3);
//    }];
    
    
    [self.lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.equalTo(@0.5);
        make.left.equalTo(self.contentView);
        make.width.equalTo(@(SCREEN_width));
        make.bottom.equalTo(self.contentView.mas_bottom).offset(0);
    }];
}

@end
